package file;

import java.io.File;

public class Test3 {
    public static void main(String[] args) {
        String fileName = "./a/b/c/d/e/f";
        while (fileName.length() > 1) {
            File dir = new File(fileName);
            File[] files = dir.listFiles();
            if (files.length > 0) {
                for (File f : files) {
                    f.delete();
                }
                System.out.println("删除全部文件");
            }
            dir.delete();
            System.out.println("删除目录");
            fileName = fileName.substring(0, fileName.length() - 2);
            System.out.println(fileName);
        }
    }
    public static void deleteFile(File f){
        if(f.isDirectory()){
            f.delete();
        }
    }
}

